; Music of Switch Blade (1990) (Gremlin Graphics) (Ben Daglish)
; Ripped by Megachur the 23/11/2006

	write "SWITCHBL.BIN"

music_date_rip	equ &17b6
music_adr	equ &4000
first_theme	equ 0
last_theme	equ 2

	read "music_header_v1_0.asm"

;&4000
	jp l40d7	; init
	jp l417d	; play
.l4006
.music_end
	db #00
	jp l4011	; init sound effects
;
.stop_music
;
	xor a
	ld (l4006),a
	jp l5182
.l4011
	push ix
	push iy
	ld ix,l509d
	ld l,a
	ld e,a
	ld h,#00
	ld d,h
	add hl,hl
	add hl,de
	add hl,hl
	add hl,hl
	add hl,de
	ld iy,l4f60
	ex de,hl
	add iy,de
	ld l,(iy+#0a)
	ld h,(iy+#0b)
	ld c,(iy+#0c)
	call l50da
	set 7,(ix+#11)
	pop iy
	pop ix
	ret
.l4046 equ $ + 7
.l4040 equ $ + 1
.l403f
	db #00,#de,#4d,#f8,#49,#f9,#49,#fc
.l404e equ $ + 7
.l404c equ $ + 5
.l404b equ $ + 4
.l404a equ $ + 3
.l4049 equ $ + 2
.l4048 equ $ + 1
	db #4e,#05,#00,#00,#04,#ff,#06,#00
.l4054 equ $ + 5
	db #94,#4e,#01,#03,#40,#00,#66,#77
.l4058 equ $ + 1
	db #23,#00,#11,#ae,#00,#33,#00,#ae
.l4061 equ $ + 2
.l4060 equ $ + 1
.l405f
	db #00,#10,#29,#4e,#02,#4a,#03,#4a
.l406d equ $ + 6
.l406c equ $ + 5
.l406b equ $ + 4
.l406a equ $ + 3
.l4069 equ $ + 2
.l4067
	db #1a,#4f,#05,#00,#00,#04,#ff,#06
.l4075 equ $ + 6
.l406f
	db #00,#b4,#4e,#01,#03,#40,#00,#02
.l4079 equ $ + 2
	db #03,#02,#00,#00,#00,#fa,#ff,#ec
.l4082 equ $ + 3
.l4081 equ $ + 2
.l4080 equ $ + 1
	db #ff,#00,#20,#4a,#4e,#0e,#4a,#16
.l408e equ $ + 7
.l408d equ $ + 6
.l408c equ $ + 5
.l408b equ $ + 4
.l408a equ $ + 3
.l4088 equ $ + 1
	db #4a,#38,#4f,#0c,#0c,#00,#04,#ff
.l4096 equ $ + 7
.l4090 equ $ + 1
	db #44,#06,#b6,#4e,#01,#01,#86,#00
.l409a equ $ + 3
	db #03,#03,#02,#00,#00,#00,#fb,#ff
.l40a2 equ $ + 3
.l40a1 equ $ + 2
	db #ef,#ff,#00,#00,#0a,#14,#1e,#28
	db #32,#3c,#46,#50,#5a,#64,#6e,#78
	db #82,#8c,#96,#6e,#78,#14,#1e,#28
	db #32,#3c,#46,#50,#5a,#64,#6e,#78
	db #82,#8c,#96,#64,#0a,#14,#1e,#28
	db #32,#3c,#46,#50,#5a,#64,#6e,#78
.l40d5 equ $ + 6
.l40d4 equ $ + 5
.l40d3 equ $ + 4
.l40d2 equ $ + 3
	db #82,#8c,#96,#00,#01,#ff,#64
.l40d6
	db #ef
;
.init_music	; 0 -> 2
.l40d7
;
	push af
	call l5182
	pop af
	ld l,a
	add a
	add l
	add a
	ld hl,l4cf1
	add l
	ld l,a
	jr nc,l40e8
	inc h
.l40e8
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (l4040),de
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (l4061),de
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (l4082),de
	xor a
	ld (l4049),a
	ld (l406a),a
	ld (l408b),a
	ld (l404e),a
	ld (l406f),a
	ld (l4090),a
	ld (l4054),a
	ld (l4075),a
	ld (l4096),a
	ld (l4058),a
	ld (l4079),a
	ld (l409a),a
	ld (l405f),a
	ld (l4080),a
	ld (l40a1),a
	cpl
	ld (l404a),a
	ld (l406b),a
	ld (l408c),a
	ld a,#01
	ld (l4048),a
	ld (l4069),a
	ld (l408a),a
	ld (l404b),a
	ld (l406c),a
	ld (l408d),a
	ld hl,l40a2
	ld bc,#030a
.l4152
	xor a
.l4153
	ld (hl),a
	inc hl
	add c
	ld (hl),a
	inc hl
	add c
	cp #a0
	jr nz,l4153
	djnz l4152
	ld hl,l4ed4
	ld (l4046),hl
	ld (l4067),hl
	ld (l4088),hl
	ld a,#ff
	ld (l404c),a
	ld (l406d),a
	ld (l408e),a
	ld (l4006),a
	ld (l40d4),a
	ret
;
.play_music
.l417d
;
	call l51c3
	ld a,(l4006)
	and a
	ret z
	ld a,(l404c)
	ld hl,l406d
	or (hl)
	ld hl,l408e
	or (hl)
	ld (l4006),a
	jr nz,l41a7
	xor a
	ld (l4006),a
	ld a,(l509c)
	and #3f
	cp #3f
	ret z
	ld a,#01
	ld (l4006),a
	ret
.l41a7
	ld iy,l403f
	ld ix,l509d
	call l41c5
	ld iy,l4060
	ld ix,l50b1
	call l41c5
	ld iy,l4081
	ld ix,l50c5
.l41c5
	call l4390
	call l4420
	ld a,(iy+#0b)
	and a
	jp z,l4266
.l41d2
	dec (iy+#09)
	jr z,l41e9
	ld a,(iy+#03)
	ld (iy+#05),a
	ld a,(iy+#04)
	ld (iy+#06),a
	ld (iy+#0b),#00
	jr l4266
.l41e9
	ld (iy+#09),#01
	ld l,(iy+#01)
	ld h,(iy+#02)
.l41f3
	ld a,(hl)
	cp #80
	jr c,l4246
	cp #fd
	jr nz,l4202
	inc hl
	inc hl
	inc hl
	jp l41f3
.l4202
	cp #fc
	jr nz,l420a
	inc hl
	jp l41f3
.l420a
	cp #fe
	jr nz,l4217
	inc hl
	ld a,(hl)
	ld (iy+#0a),a
	inc hl
	jp l41f3
.l4217
	cp #ff
	jr nz,l4220
	xor a
	ld (iy+#0d),a
	ret
.l4220
	cp #c0
	jr nc,l422d
	and #1f
	ld (iy+#09),a
	inc hl
	jp l41f3
.l422d
	and #0f
	add (iy+#00)
	ld de,l40a2
	add e
	ld e,a
	jr nc,l423a
	inc d
.l423a
	inc hl
	ld a,(hl)
	inc hl
	add a
	ld c,a
	add a
	add a
	add c
	ld (de),a
	jp l41f3
.l4246
	ld (iy+#0b),#00
	inc hl
	ld (iy+#01),l
	ld (iy+#02),h
	ld c,a
	ld b,#00
	ld hl,l4c97
	add hl,bc
	ld e,(hl)
	ld hl,l4cc4
	add hl,bc
	ld d,(hl)
	ld (iy+#03),e
	ld (iy+#04),d
	jr l426c
.l4266
	ld e,(iy+#05)
	ld d,(iy+#06)
.l426c
	dec (iy+#0c)
	jr z,l427e
	ld a,(de)
	cp #80
	call nc,l431f
	ld (iy+#05),e
	ld (iy+#06),d
	ret
.l427e
	ld a,(de)
	cp #80
	jr c,l428f
	call l431f
	ld a,(iy+#0b)
	and a
	jr z,l427e
	jp l41d2
.l428f
	cp #7f
	jp z,l4312
	cp #7e
	jr nz,l42a1
	inc de
	ld a,(de)
	ld l,a
	inc de
	ld a,(de)
	ld h,a
	jp l42e5
.l42a1
	add (iy+#0a)
	ld (iy+#0e),a
	ld hl,l5016
	add a
	ld c,a
	ld b,#00
	add hl,bc
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	ld a,(iy+#15)
	ld (iy+#19),a
	and a
	jr z,l42e5
	ld a,(iy+#16)
	ld (iy+#1a),a
	ld a,(iy+#17)
	ld (iy+#1b),a
	ld a,(iy+#18)
	add (iy+#0e)
	push hl
	ld hl,l5016
	add a
	ld c,a
	add hl,bc
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a
	pop bc
	and a
	sbc hl,bc
	ld (iy+#1e),l
	ld (iy+#1f),h
	ld h,b
	ld l,c
.l42e5
	ld a,(iy+#0f)
	or #c0
	ld (iy+#14),a
	inc de
	ld a,(de)
	inc de
	ld (iy+#0c),a
	ld c,a
	ld (iy+#05),e
	ld (iy+#06),d
	ld e,(iy+#07)
	ld a,(iy+#08)
	ld hy,a
	ld ly,e
	bit 7,(ix+#11)
	ret nz
	ld a,(iy+#20)
	ld (l40d2),a
	jp l50da
.l4312
	inc de
	ld a,(de)
	inc de
	ld (iy+#0c),a
	ld (iy+#05),e
	ld (iy+#06),d
	ret
.l431f
	ld a,(de)
	cp #8c
	jr nc,l433d
	and #0f
	add (iy+#00)
	ld c,a
	ld b,#00
	ld hl,l40a2
	add hl,bc
	ld c,(hl)
	ld hl,l4ed4
	add hl,bc
	ld (iy+#07),l
	ld (iy+#08),h
	inc de
	ret
.l433d
	cp #ff
	jr nz,l4346
	ld (iy+#0b),#ff
	ret
.l4346
	cp #c0
	jr nc,l4351
	and #0f
	ld (iy+#0f),a
	inc de
	ret
.l4351
	inc de
	cp #c1
	jr nz,l435b
	ld (iy+#15),#00
	ret
.l435b
	cp #c0
	jr nz,l4373
	ld (iy+#15),#ff
	ld a,(de)
	inc de
	ld (iy+#16),a
	ld a,(de)
	inc de
	ld (iy+#17),a
	ld a,(de)
	inc de
	ld (iy+#18),a
	ret
.l4373
	cp #fc
	jr nz,l437c
	ld (iy+#20),#00
	ret
.l437c
	cp #fd
	jr nz,l438f
	ld (iy+#20),#ff
	ld a,(de)
	inc de
	ld (l40d3),a
	ld a,(de)
	inc de
	ld (l40d5),a
	ret
.l438f
	ret
.l4390
	bit 7,(ix+#11)
	ret nz
	ld a,(iy+#14)
	bit 7,a
	ret z
	and #3f
	jr nz,l43a4
	res 7,(iy+#14)
	ret
.l43a4
	ld d,#07
	bit 6,(iy+#14)
	jr nz,l43d8
	dec (iy+#12)
	ret nz
	dec (iy+#13)
	jp z,l43d8
	ld l,(iy+#10)
	ld h,(iy+#11)
	inc l
	ld (iy+#10),l
	jp nz,l43c7
	inc h
	ld (iy+#11),h
.l43c7
	ld a,(hl)
	and d
	ld (iy+#12),a
	ld a,(hl)
	rrca
	rrca
	rrca
	and #1f
	add (iy+#0e)
	jp l440d
.l43d8
	ld hl,l4784
	ld a,(iy+#14)
	add a
	add a
	add a
	ld e,a
	add hl,de
	bit 7,(hl)
	jr nz,l43f2
	bit 6,(iy+#14)
	jr nz,l43f2
	ld (iy+#13),#01
	ret
.l43f2
	res 6,(iy+#14)
	ld a,(hl)
	rrca
	rrca
	rrca
	and d
	ld (iy+#12),a
	ld a,(hl)
	and d
	inc a
	ld (iy+#13),a
	ld (iy+#10),l
	ld (iy+#11),h
	ld a,(iy+#0e)
.l440d
	add a
	ld hl,l5016
	add l
	ld l,a
	jr nc,l4416
	inc h
.l4416
	ld a,(hl)
	inc hl
	ld (ix+#03),a
	ld a,(hl)
	ld (ix+#04),a
	ret
.l4420
	ld a,(iy+#19)
	and a
	ret z
	jp p,l4481
	ld d,#00
	ld e,(iy+#1b)
	ld hl,#0000
	ld c,(iy+#1e)
	ld a,(iy+#1f)
	and a
	jp m,l4458
	ld b,#10
.l443c
	rl c
	rla
	adc hl,hl
	sbc hl,de
	jr nc,l4446
	add hl,de
.l4446
	ccf
	djnz l443c
	rl c
	rla
	ld (iy+#1c),c
	ld (iy+#1d),a
	ld (iy+#19),#01
	jr l4481
.l4458
	cpl
	ld b,a
	ld a,c
	cpl
	ld c,a
	inc bc
	ld a,b
	ld b,#10
.l4461
	rl c
	rla
	adc hl,hl
	sbc hl,de
	jr nc,l446b
	add hl,de
.l446b
	ccf
	djnz l4461
	rl c
	rla
	cpl
	ld b,a
	ld a,c
	cpl
	ld c,a
	inc bc
	ld (iy+#1c),c
	ld (iy+#1d),b
	ld (iy+#19),#01
.l4481
	ld a,(iy+#1a)
	and a
	jr z,l448b
	dec (iy+#1a)
	ret
.l448b
	ld a,(iy+#1b)
	and a
	jr z,l44a7
	dec (iy+#1b)
	ld a,(iy+#1c)
	add (ix+#12)
	ld (ix+#12),a
	ld a,(iy+#1d)
	adc (ix+#13)
	ld (ix+#13),a
	ret
.l44a7
	ld a,(iy+#1e)
	ld (ix+#12),a
	ld a,(iy+#1f)
	ld (ix+#13),a
	ld (iy+#19),#00
	ret
.s00
	db #fd,#02,#64,#80,#91,#2a,#07,#81
	db #2a,#07,#80,#2a,#07,#90,#fc,#82
	db #19,#07,#fd,#01,#64,#91,#80,#2a
	db #07,#2a,#07,#80,#91,#2a,#07,#81
	db #2a,#07,#80,#2a,#07,#90,#fc,#82
	db #19,#07,#fd,#01,#64,#91,#80,#2a
	db #07,#2a,#07,#80,#92,#2a,#07,#81
	db #2a,#07,#80,#2a,#07,#90,#fc,#82
	db #19,#07,#fd,#01,#64,#92,#80,#2a
	db #07,#2a,#07,#80,#92,#2a,#07,#81
	db #2a,#07,#80,#2a,#07,#90,#fc,#82
	db #19,#07,#fd,#01,#64,#92,#80,#2a
	db #07,#2a,#07,#ff
.s01
	db #83,#1e,#02,#1e
	db #05,#1e,#07,#1e,#07,#1b,#07,#1b
	db #07,#1b,#07,#17,#02,#17,#05,#17
	db #07,#17,#07,#14,#07,#14,#07,#14
	db #07,#ff
.s02
	db #81,#36,#07,#36,#07,#36
	db #07,#90,#84,#09,#07,#0d,#07,#12
	db #07,#ff
.s03
	db #fc,#90,#84,#0f,#15,#83
	db #1b,#07,#1b,#07,#1b,#07,#17,#02
	db #17,#05,#17,#07,#17,#07,#14,#07
	db #14,#07,#14,#07,#84,#09,#15,#83
	db #1b,#07,#1b,#07,#1b,#07,#17,#02
	db #17,#05,#17,#07,#17,#07,#14,#07
	db #14,#07,#14,#07,#ff
.s04
	db #81,#36,#07
	db #36,#07,#36,#07,#36,#07,#36,#07
	db #36,#07,#ff
.s05
	db #83,#20,#02,#20,#05
	db #20,#07,#20,#0e,#20,#02,#20,#05
	db #20,#07,#20,#15,#20,#02,#20,#05
	db #20,#07,#20,#07,#ff
.s06
	db #84,#0f,#15
	db #83,#1b,#07,#1b,#07,#1b,#07,#17
	db #02,#17,#05,#17,#07,#17,#07,#14
	db #07,#14,#07,#14,#07,#84,#09,#15
	db #83,#1b,#07,#1b,#07,#1b,#07,#17
	db #02,#17,#05,#17,#07,#17,#07,#84
	db #09,#07,#0f,#07,#15,#07,#ff
.s07
	db #fd
	db #01,#64,#80,#93,#2d,#07,#81,#2d
	db #07,#80,#2d,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#93,#80,#2d,#07
	db #2d,#07,#80,#93,#2d,#07,#81,#2d
	db #07,#80,#2d,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#93,#80,#2d,#07
	db #2d,#07,#80,#94,#2d,#07,#81,#2d
	db #07,#80,#2d,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#94,#80,#2d,#07
	db #2d,#07,#80,#94,#2d,#07,#81,#2d
	db #07,#80,#2d,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#94,#80,#2d,#07
	db #2d,#07,#ff
.s08
	db #86,#c0,#07,#07,#01
	db #27,#7e,#c0,#03,#03,#ff
;.s09
	db #28,#0e
	db #c1,#25,#0e,#27,#0e,#ff
.s09
	db #86,#c0
	db #03,#03,#02,#28,#7e,#c0,#02,#02
	db #02,#2d,#0e,#c1,#2d,#0e,#2a,#07
	db #28,#07,#c0,#03,#03,#02,#28,#7e
	db #c0,#02,#02,#02,#2d,#07,#c1,#2d
	db #07,#2a,#07,#2d,#07,#2a,#07,#28
	db #07,#ff
.s10
	db #fd,#01,#64,#80,#95,#2d
	db #07,#81,#2d,#07,#80,#2d,#07,#81
	db #2d,#07,#80,#2d,#07,#2d,#07,#90
	db #fc,#82,#19,#07,#fd,#01,#64,#81
	db #95,#2d,#07,#80,#2d,#07,#81,#2d
	db #07,#80,#2d,#07,#2d,#07,#ff
.s11
	db #fd
	db #01,#64,#80,#96,#2c,#07,#81,#2c
	db #07,#80,#2c,#07,#81,#2c,#07,#80
	db #2c,#07,#2c,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#81,#96,#2c,#07
	db #80,#2c,#07,#81,#2c,#07,#80,#2c
	db #07,#2c,#07,#fd,#01,#64,#80,#97
	db #2c,#07,#81,#2c,#07,#80,#2c,#07
	db #81,#2c,#07,#80,#2c,#07,#2c,#07
	db #90,#fc,#82,#19,#07,#fd,#01,#64
	db #81,#97,#2c,#07,#80,#2c,#07,#90
	db #fc,#82,#19,#07,#fd,#01,#64,#97
	db #80,#2c,#07,#2c,#07,#fc,#ff
.s12
	db #85
	db #09,#0e,#09,#07,#10,#07,#13,#07
	db #15,#07,#09,#0e,#10,#0e,#13,#07
	db #15,#07,#ff
.s13
	db #85,#10,#0e,#10,#07
	db #0e,#07,#0b,#07,#04,#07,#10,#0e
	db #0e,#0e,#09,#07,#04,#07,#01,#0e
	db #01,#07,#0d,#07,#0b,#07,#0d,#07
	db #01,#0e,#01,#07,#0d,#07,#0b,#07
	db #0d,#07,#ff
.s14
	db #86,#25,#2a,#c0,#02
	db #03,#02,#23,#0e,#23,#0e,#c1,#23
	db #07,#21,#07,#23,#46,#21,#07,#23
	db #07,#c0,#02,#03,#01,#23,#0e,#c1
	db #23,#0e,#21,#0e,#23,#0e,#21,#0e
	db #23,#0e,#c0,#02,#03,#02,#23,#54
	db #23,#2a,#c0,#02,#03,#02,#23,#0e
	db #c1,#28,#07,#c0,#02,#03,#02,#23
	db #07,#c1,#23,#07
.l4784
	db #21,#07,#23,#46,#21,#07,#23,#07
	db #c0,#02,#03,#01,#23,#0e,#c1,#23
	db #0e,#21,#0e,#23,#0e,#21,#0e,#23
	db #0e,#c0,#02,#03,#02,#23,#0e,#c1
	db #23,#0e,#21,#0e,#23,#0e,#21,#0e
	db #1e,#07,#1c,#07,#1e,#15,#ff
.s15
	db #90
	db #84,#06,#0e,#12,#0e,#06,#07,#06
	db #07,#06,#0e,#12,#0e,#06,#07,#06
	db #07,#06,#0e,#12,#0e,#06,#07,#06
	db #07,#06,#0e,#12,#0e,#10,#07,#0d
	db #07,#ff
.s16
	db #88,#36,#15,#ff
.s17
	db #82,#19
	db #0e,#ff
.s18
	db #82,#19,#0e,#19,#07,#19
	db #07,#ff
.s19
	db #90,#84,#06,#0e,#12,#0e
	db #06,#07,#06,#07,#06,#0e,#12,#0e
	db #06,#07,#06,#07,#06,#0e,#12,#0e
	db #06,#07,#06,#07,#83,#1e,#07,#1e
	db #07,#1e,#07,#19,#07,#19,#07,#19
	db #07,#ff
.s20
	db #80,#c0,#04,#04,#02,#36
	db #4d,#34,#4d,#31,#4d,#2f,#23,#2f
	db #05,#2c,#05,#2f,#23,#2f,#05,#2c
	db #05,#2f,#23,#2f,#05,#2c,#05,#28
	db #8a,#c1,#2a,#07,#2c,#07,#2f,#07
	db #2c,#07,#2f,#07,#31,#07,#2f,#07
	db #31,#07,#33,#07,#36,#07,#38,#07
	db #3b,#07,#3d,#07,#3b,#07,#38,#07
	db #3b,#07,#38,#07,#36,#07,#33,#07
	db #31,#07,#2f,#07,#2c,#07,#25,#07
	db #27,#07,#27,#2a,#c0,#03,#03,#02
	db #25,#0e,#25,#0e,#c1,#25,#07,#23
	db #07,#25,#2a,#c0,#03,#03,#02,#25
	db #07,#c1,#25,#07,#23,#07,#25,#07
	db #23,#07,#20,#07,#20,#54,#7f,#54
	db #27,#2a,#c0,#03,#03,#02,#25,#0e
	db #c1,#2a,#07,#c0,#03,#03,#02,#25
	db #07,#c1,#25,#07,#23,#07,#25,#2a
	db #c0,#03,#03,#02,#25,#07,#c1,#25
	db #07,#23,#07,#25,#07,#23,#07,#20
	db #07,#20,#54,#7f,#54,#27,#2a,#c0
	db #03,#03,#02,#25,#0e,#c1,#2a,#07
	db #c0,#03,#03,#02,#25,#07,#c1,#25
	db #07,#23,#07,#25,#2a,#c0,#03,#03
	db #02,#25,#07,#c1,#25,#07,#23,#07
	db #25,#07,#23,#07,#20,#07,#20,#2a
	db #83,#20,#07,#20,#07,#20,#07,#1b
	db #07,#1b,#07,#1b,#07,#ff
.s21
	db #fd,#02
	db #64,#80,#97,#28,#07,#81,#28,#07
	db #80,#28,#07,#90,#fc,#82,#19,#07
	db #fd,#01,#64,#97,#80,#28,#07,#28
	db #07,#80,#97,#28,#07,#81,#28,#07
	db #80,#28,#07,#90,#fc,#82,#19,#07
	db #fd,#01,#64,#97,#80,#28,#07,#28
	db #07,#80,#97,#2a,#07,#81,#2a,#07
	db #80,#2a,#07,#90,#fc,#82,#19,#07
	db #fd,#01,#64,#97,#80,#2a,#07,#2a
	db #07,#80,#97,#2a,#07,#81,#2a,#07
	db #80,#2a,#07,#90,#fc,#82,#19,#07
	db #fd,#01,#64,#97,#80,#2a,#07,#2a
	db #07,#ff
.s22
	db #80,#96,#2a,#07,#81,#2a
	db #07,#80,#2a,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#96,#80,#2a,#07
	db #2a,#07,#80,#96,#2a,#07,#81,#2a
	db #07,#80,#2a,#07,#90,#fc,#82,#19
	db #07,#fd,#01,#64,#96,#80,#2a,#07
	db #2a,#07,#ff
.s23
	db #fd,#01,#64,#80,#95
	db #2f,#07,#81,#2f,#07,#80,#2f,#07
	db #81,#2f,#07,#80,#2f,#07,#2f,#07
	db #90,#fc,#82,#19,#07,#fd,#01,#64
	db #81,#95,#2f,#07,#80,#2f,#07,#81
	db #2f,#07,#80,#2f,#07,#2f,#07,#80
	db #95,#2d,#07,#81,#2d,#07,#80,#2d
	db #07,#81,#2d,#07,#80,#2d,#07,#2d
	db #07,#90,#fc,#82,#19,#07,#fd,#01
	db #64,#81,#96,#2c,#07,#80,#2c,#07
	db #81,#2c,#07,#80,#2c,#07,#2c,#07
	db #ff
.s24
	db #90,#84,#0b,#0e,#17,#0e,#0b
	db #07,#0b,#07,#0b,#0e,#17,#0e,#0b
	db #07,#0b,#07,#09,#0e,#15,#0e,#09
	db #07,#09,#07,#08,#0e,#14,#0e,#08
	db #07,#08,#07,#ff
.s25
	db #84,#06,#0a,#06
	db #0a,#06,#0a,#06,#0a,#ff
.s26
	db #87,#06
	db #0a,#06,#0a,#80,#3d,#0a,#87,#06
	db #0a,#ff
.s27
	db #96,#80,#31,#28,#34,#28
	db #38,#28,#36,#28,#ff
.s28
	db #81,#95,#2d
	db #a0,#2c,#a0,#2b,#a0,#2a,#a0,#2d
	db #a0,#2c,#a0,#2b,#a0,#28,#a0,#96
	db #27,#a0,#95,#28,#a0,#96,#27,#8c
	db #90,#82,#20,#05,#20,#05,#1b,#05
	db #1b,#05,#ff
.s29
	db #84,#06,#0a,#06,#0a
	db #fd,#02,#14,#06,#0a,#fc,#06,#0a
	db #ff
.s30
	db #80,#31,#28,#34,#28,#38,#28
	db #36,#14,#82,#19,#0a,#19,#05,#19
	db #05,#ff
.s31
	db #84,#06,#0a,#06,#0a,#82
	db #19,#0a,#84,#08,#0a,#08,#0a,#08
	db #0a,#82,#19,#0a,#84,#09,#0a,#09
	db #0a,#09,#0a,#82,#19,#0a,#84,#0b
	db #0a,#0b,#0a,#0b,#0a,#82,#19,#0a
	db #19,#0a,#84,#0d,#0a,#0d,#0a,#82
	db #19,#0a,#84,#0e,#0a,#0e,#0a,#0e
	db #0a,#82,#19,#0a,#84,#10,#0a,#10
	db #0a,#10,#0a,#82,#19,#0a,#84,#0b
	db #14,#03,#0a,#04,#05,#05,#0f,#ff
.s32
	db #81,#7f,#14,#80,#91,#1e,#0a,#81
	db #95,#1c,#28,#96,#19,#1e,#19,#0a
	db #80,#19,#0a,#1b,#0a,#81,#1b,#14
	db #19,#1e,#19,#0a,#19,#0a,#80,#93
	db #1a,#0a,#81,#1a,#1e,#95,#1c,#0a
	db #96,#19,#0a,#97,#17,#0a,#95,#17
	db #1e,#82,#19,#0a,#19,#05,#19,#05
	db #ff
.s33
	db #81,#91,#2a,#0a,#2a,#0a,#2a
	db #0a,#95,#28,#0a,#28,#0a,#28,#0a
	db #28,#0a,#96,#25,#0a,#25,#0a,#25
	db #0a,#25,#0a,#27,#0a,#27,#0a,#27
	db #0a,#27,#0a,#25,#0a,#25,#0a,#25
	db #0a,#25,#0a,#93,#26,#0a,#26,#0a
	db #26,#0a,#26,#0a,#95,#28,#0a,#28
	db #0a,#28,#0a,#28,#0a,#96,#27,#0a
	db #27,#0a,#27,#0a,#27,#0a,#27,#0a
	db #ff
.s34
	db #80,#93,#2d,#0a,#2d,#0a,#2d
	db #0a,#95,#99,#2c,#0a,#2c,#0a,#2c
	db #0a,#2c,#0a,#93,#2d,#0a,#2d,#0a
	db #2d,#0a,#2d,#0a,#95,#2f,#0a,#2f
	db #0a,#2f,#0a,#2f,#0a,#93,#2d,#0a
	db #2d,#0a,#2d,#0a,#2d,#0a,#97,#2d
	db #0a,#2d,#0a,#2d,#0a,#2d,#0a,#99
	db #2c,#0a,#2c,#0a,#2c,#0a,#2c,#0a
	db #95,#2f,#0a,#2f,#0a,#2f,#0a,#2f
	db #0a,#2f,#0a,#ff
.s35
	db #91,#2a,#a0,#7f
	db #a0,#90,#86,#19,#78,#17,#0d,#1c
	db #0d,#17,#0e,#19,#78,#17,#0d,#1c
	db #0d,#20,#0e,#1e,#78,#20,#0d,#1c
	db #0d,#23,#0e,#1e,#78,#20,#0d,#1c
	db #0d,#17,#0e,#19,#78,#17,#0d,#1c
	db #0d,#19,#0e,#1b,#78,#1e,#0d,#1b
	db #0d,#17,#0e,#ff
.s36
	db #90,#87,#06,#0a
	db #06,#0a,#06,#0a,#06,#0a,#06,#0a
	db #06,#0a,#06,#0a,#06,#0a,#06,#0a
	db #06,#0a,#06,#0a,#06,#0a,#83,#20
	db #05,#20,#05,#20,#05,#1d,#05,#1d
	db #05,#1d,#05,#19,#05,#19,#05,#ff
.s37
	db #81,#91,#2a,#78,#2d,#0f,#28,#0f
	db #80,#2a,#0a,#7f,#78,#81,#2d,#0f
	db #2f,#0f,#80,#2a,#0a,#7f,#78,#81
	db #2d,#0f,#28,#0f,#80,#2a,#0a,#7f
	db #78,#81,#2d,#0f,#2f,#0f,#96,#80
	db #2c,#0a,#7f,#78,#81,#2d,#0f,#2f
	db #0f,#96,#80,#2c,#0a,#7f,#78,#81
	db #2c,#0f,#97,#2a,#0f,#91,#80,#2a
	db #0a,#7f,#78,#81,#2c,#0f,#97,#2a
	db #0f,#91,#80,#2a,#0a,#7f,#78,#81
	db #2d,#0f,#2f,#0f,#96,#80,#2c,#0a
	db #7f,#78,#81,#2d,#0f,#2f,#0f,#96
	db #80,#2c,#0a,#7f,#78,#81,#2c,#0f
	db #97,#2a,#0f,#91,#80,#2a,#0a,#ff
.s38
	db #84,#09,#0a,#09,#0a,#fd,#02,#14
	db #0b,#0a,#fc,#04,#0a,#ff
.s39
	db #84,#04
	db #0a,#04,#0a,#fd,#02,#14,#0b,#0a
	db #fc,#06,#0a,#ff
.s40
	db #84,#06,#0c,#06
	db #04,#06,#04,#06,#04,#06,#0c,#06
	db #0c,#ff
.s41
	db #80,#95,#21,#0c,#21,#04
	db #21,#04,#21,#04,#21,#0c,#21,#0c
	db #23,#0c,#23,#04,#23,#04,#23,#04
	db #23,#0c,#93,#21,#22,#7f,#02,#ff
.s42
	db #ff
.s43
	db #ff
.s44
	db #ff
.l4c97
	db s00,s01,s02,s03,s04,s05,s06,s07
	db s08,s09,s10,s11,s12,s13,s14,s15
	db s16,s17,s18,s19,s20,s21,s22,s23
	db s24,s25,s26,s27,s28,s29,s30,s31
	db s32,s33,s34,s35,s36,s37,s38,s39
	db s40,s41,s42,s43,s44
;	db #b8,#1c,#3a,#4a,#7d,#8b,#a5,#d7
;	db #3b,#4e,#7a,#a7,#07,#1b,#43,#b3
;	db #d6,#da,#de,#e6,#0e,#ea,#4e,#7f
;	db #d5,#f8,#02,#0e,#19,#3f,#4d,#5e
;	db #ac,#e5,#2d,#78,#b0,#dc,#4c,#5a
;	db #68,#76,#94,#95,#96
.l4cc4
	db s00/&100,s01/&100,s02/&100,s03/&100,s04/&100,s05/&100,s06/&100,s07/&100
	db s08/&100,s09/&100,s10/&100,s11/&100,s12/&100,s13/&100,s14/&100,s15/&100
	db s16/&100,s17/&100,s18/&100,s19/&100,s20/&100,s21/&100,s22/&100,s23/&100
	db s24/&100,s25/&100,s26/&100,s27/&100,s28/&100,s29/&100,s30/&100,s31/&100
	db s32/&100,s33/&100,s34/&100,s35/&100,s36/&100,s37/&100,s38/&100,s39/&100
	db s40/&100,s41/&100,s42/&100,s43/&100,s44/&100
;	db #44/&100,#45/&100,#45,#45,#45,#45,#45,#45
;	db #46,#46,#46,#46,#47,#47,#47,#47
;	db #47,#47,#47,#47,#48,#48,#49,#49
;	db #49,#49,#4a,#4a,#4a,#4a,#4a,#4a
;	db #4a,#4a,#4b,#4b,#4b,#4b,#4c,#4c
;	db #4c,#4c,#4c,#4c,#4c
.l4cf1
	dw l4d03,l4d5e,l4daa
	dw l4ddc,l4e23,l4e44
	dw l4e7e,l4e81,l4e88
.l4d03
	db #83,#00,#fe,#fd,#84,#00,#fe,#00
	db #84,#07,#0a,#fe,#02,#0a,#fe,#00
	db #0b,#0a,#fe,#02,#0a,#fe,#00,#0b
	db #fe,#f4,#c4,#07,#83,#0f,#13,#c4
	db #04,#fe,#f6,#84,#0f,#0c,#fe,#f8
	db #0c,#fe,#f6,#0f,#0c,#fe,#f8,#0c
	db #fe,#f6,#0f,#0c,#fe,#f8,#0c,#fe
	db #fb,#0c,#fe,#00,#84,#07,#fe,#02
	db #84,#07,#0a,#fe,#04,#0a,#fe,#02
	db #0b,#0a,#fe,#04,#0a,#fe,#02,#0b
	db #17,#00,#17,#00,#17,#00,#17,#00
	db #17,#00,#ff
.l4d5e
	db #85,#01,#05,#90,#04
	db #08,#08,#09,#0e,#9d,#10,#11,#12
	db #fe,#02,#84,#00,#15,#00,#15,#00
	db #15,#16,#fe,#03,#84,#03,#fe,#05
	db #84,#03,#fe,#02,#0c,#fe,#04,#0c
	db #fe,#02,#0d,#0c,#fe,#04,#0c,#fe
	db #02,#0d,#18,#fe,#05,#03,#fe,#02
	db #18,#fe,#05,#03,#fe,#02,#18,#fe
	db #05,#03,#fe,#02,#18,#fe,#05,#03
	db #fe,#02,#18,#fe,#05,#03,#ff
.l4daa
	db #8b
	db #04,#02,#83,#03,#06,#fe,#03,#84
	db #03,#fe,#00,#0c,#fe,#02,#0c,#fe
	db #00,#0d,#0c,#fe,#02,#0c,#fe,#00
	db #0d,#fe,#f4,#84,#0f,#fe,#00,#c0
	db #09,#14,#fe,#03,#c4,#07,#84,#03
	db #c4,#04,#fe,#02,#08,#08,#09,#0e
	db #ff
.l4ddc
	db #88,#19,#9c,#1d,#fe,#f9,#84
	db #1d,#8c,#1d,#fe,#00,#84,#1f,#98
	db #1d,#fe,#03,#84,#1d,#fe,#05,#84
	db #1d,#fe,#00,#1f,#1f,#fe,#02,#1f
	db #1f,#8f,#1d,#26,#fe,#00,#87,#1d
	db #fe,#02,#27,#87,#1d,#26,#fe,#00
	db #87,#1d,#fe,#02,#27,#98,#1d,#fe
	db #05,#84,#1d,#fe,#07,#84,#1d,#fe
	db #02,#1f,#1f,#fe,#04,#1f,#1f,#ff
.l4e23
	db #c0,#0b,#c1,#0c,#88,#1a,#1c,#c0
	db #00,#fe,#0c,#84,#20,#23,#20,#20
	db #fe,#0e,#20,#20,#fe,#02,#25,#23
	db #fe,#0e,#20,#20,#fe,#10,#20,#20
	db #ff
.l4e44
	db #fe,#0c,#c0,#0a,#8c,#1b,#1e
	db #fe,#00,#c0,#00,#21,#21,#22,#22
	db #c0,#0a,#87,#1b,#1e,#c0,#00,#21
	db #21,#fe,#02,#22,#22,#84,#24,#fe
	db #00,#24,#24,#fe,#02,#24,#24,#fe
	db #00,#24,#24,#fe,#02,#c0,#0a,#87
	db #1b,#1e,#c0,#00,#21,#21,#fe,#04
	db #22,#22,#ff
.l4e7e
	db #28,#28,#ff
.l4e81
	db #fe,#11
	db #c4,#02,#28,#28,#ff
.l4e88
	db #c0,#0d,#29
	db #ff
	db #8a,#19,#39,#00,#00,#00,#00
	db #00,#8a,#19,#31,#00,#00,#00,#00
	db #00,#8a,#21,#49,#00,#00,#00,#00
	db #00,#8a,#19,#49,#00,#00,#00,#00
	db #00,#8a,#21,#39,#00,#00,#00,#00
	db #00,#8a,#19,#41,#00,#00,#00,#00
	db #00,#8a,#29,#49,#00,#00,#00,#00
	db #00,#89,#61,#00,#00,#00,#00,#00
	db #00,#8a,#19,#51,#00,#00,#00,#00
	db #00
.l4ed4
	db #7f,#fb,#00,#ff,#6d,#00,#03,#01
	db #00,#01,#7f,#fc,#00,#ff,#57,#00
	db #03,#01,#00,#01,#7f,#fb,#00,#ff
	db #7f,#00,#00,#40,#00,#03,#7f,#fc
	db #00,#ff,#70,#00,#00,#3b,#00,#01
	db #43,#fc,#00,#ff,#7f,#00,#03,#06
	db #00,#01,#7f,#fc,#00,#ff,#7f,#00
	db #03,#04,#00,#01,#50,#ff,#45,#ff
	db #7c,#14,#04,#03,#00,#01,#43,#fe
	db #00,#ff,#7f,#01,#03,#06,#00,#01
	db #7f,#eb,#00,#ff,#75,#ff,#00,#00
	db #00,#03,#7f,#ff,#00,#ff,#75,#0c
	db #03,#01,#00,#01,#08,#ff,#00,#ff
	db #65,#00,#05,#fa,#ff,#01,#7f,#f8
	db #00,#ff,#64,#fe,#00,#00,#00,#02
	db #7f,#ff,#3a,#fe,#78,#00,#03,#01
	db #00,#01,#7f,#fe,#00,#fe,#75,#00
	db #03,#02,#00,#01
.l4f60
	db #14,#f9,#0e,#fe,#6f,#03,#09,#11
	db #00,#03,#4b,#00,#22,#7d,#f7,#11
	db #ff,#5c,#00,#06,#11,#00,#03,#e1
	db #00,#0c,#7f,#fd,#1e,#ff,#7f,#03
	db #05,#25,#00,#03,#07,#00,#3f,#25
	db #fe,#5d,#ff,#7f,#04,#58,#15,#00
	db #03,#40,#00,#32,#09,#ff,#00,#00
	db #6f,#01,#02,#03,#00,#03,#01,#01
	db #01,#0e,#fe,#01,#ff,#7c,#00,#04
	db #11,#00,#01,#53,#00,#28,#07,#f9
	db #27,#ff,#63,#07,#09,#0d,#00,#03
	db #72,#00,#57,#7f,#e8,#00,#ff,#43
	db #00,#00,#43,#00,#03,#7f,#00,#14
	db #7f,#f7,#50,#ff,#78,#13,#04,#01
	db #00,#01,#2c,#00,#3b,#03,#f8,#40
	db #ff,#7f,#46,#0a,#5c,#00,#03,#96
	db #00,#67,#7f,#fe,#0e,#ff,#6b,#00
	db #07,#1b,#00,#03,#07,#00,#46,#17
	db #f9,#00,#ff,#50,#00,#00,#00,#00
	db #02,#2c,#00,#00,#7f,#f2,#00,#ff
	db #7f,#00,#00,#11,#00,#03,#5d,#00
	db #14,#7f,#f9,#00,#ff,#7f,#00,#00
	db #5c,#00,#03,#96,#01,#1e
.l5016
	dw #0547,#04fc,#04d4,#0470
	dw #0431,#03f4,#03dc,#0386
	dw #0353,#0324,#02f6,#02cc
	dw #02a4,#027e,#025a,#0238
	dw #0218,#01fa,#01de,#01c3
	dw #01aa,#0192,#017b,#0166
	dw #0152,#013f,#012d,#011c
	dw #010c,#00fd,#00ef,#00e1
	dw #00d5,#00c9,#00be,#00b3
	dw #00a9,#009f,#0096,#008e
	dw #0086,#007f,#0077,#0071
	dw #006a,#0064,#005f,#0059
	dw #0054,#0050,#004b,#0047
	dw #0043,#003f,#003c,#0038
	dw #0035,#0032,#002f,#002d
	dw #002a,#0028,#0026,#0024
	db #0022,#0020,#0018
.l509c
	db #38
.l509d
	db #fe,#f7,#09
.l50a0
	db #dc,#03
.l50a2
	db #6b,#04,#00,#01,#00,#00,#06,#00
	db #24
.l50b1 equ $ + 6
.l50ae equ $ + 3
	db #53,#fc,#4e,#01,#00,#00,#fd,#ef
	db #12
.l50b4
	db #dc,#03
.l50b6
	db #75,#04,#00,#01,#00,#00,#06,#00
	db #24,#53,#1a,#4f
.l50c2
	db #01
.l50ca equ $ + 7
.l50c8 equ $ + 5
.l50c5 equ $ + 2
	db #00,#00,#fb,#df,#24,#01,#00,#46
	db #04,#00,#01,#0c,#00,#06,#00,#24
	db #53,#38,#4f
.l50d6
	db #01,#00,#00
.l50d9
	db #28
.l50da
	ld a,ly
	ld (ix+#0f),a
	ld a,hy
	ld (ix+#10),a
	ld (ix+#03),l
	ld (ix+#04),h
	ld (ix+#06),c
	ld a,(iy+#05)
	ld (ix+#07),a
	ld a,(iy+#06)
	and #7f
	srl a
	jr nz,l50fe
	ld a,#01
.l50fe
	ld (ix+#08),a
	ld a,(iy+#07)
	ld (ix+#0b),a
	ld a,(iy+#08)
	ld (ix+#0c),a
	xor a
	ld (ix+#09),a
	ld (ix+#0a),a
	ld (ix+#12),a
	ld (ix+#13),a
	ld a,(l509c)
	or (ix+#02)
	ld c,(iy+#09)
	ld (ix+#11),c
	bit 0,c
	jr z,l512d
	and (ix+#00)
.l512d
	push af
	ld a,(l40d2)
	and a
	jr nz,l513e
	pop af
	bit 1,c
	jr z,l5152
	and (ix+#01)
	jr l5152
.l513e
	xor a
	ld (l40d2),a
	ld a,(ix+#01)
	ld (l40d6),a
	ld a,(l40d3)
	ld (l40d4),a
	pop af
	and (ix+#01)
.l5152
	ld (l509c),a
	bit 2,c
	jr nz,l5163
	ld hl,l5305
	ld (ix+#0d),l
	ld (ix+#0e),h
	ret
.l5163
	call l53bd
	ld a,(iy+#00)
	ld c,#0d
	call l53d4
	ld a,(iy+#04)
	ld c,#0b
	call l53d4
	inc c
	xor a
	call l53d4
	ld (ix+#05),#ff
	jp l53c9
.l5182
	call l53bd
	ld c,#07
	ld a,(l509c)
	or #3f
	ld (l509c),a
	call l53d4
	xor a
	inc c
	call l53d4
	inc c
	call l53d4
	inc c
	call l53d4
	ld a,#01
	inc c
	call l53d4
	inc c
	xor a
	call l53d4
	inc c
	call l53d4
	ld (l50ae),a
	ld (l50c2),a
	ld (l50d6),a
	ld (l50a2),a
	ld (l50b6),a
	ld (l50ca),a
	jp l53c9
.l51c3
	ld a,(l509c)
	and #3f
	cp #3f
	ret z
	ld ix,l509d
	call l52d3
	ld ix,l50b1
	call l52d3
	ld ix,l50c5
	call l52d3
	ld hl,l40d4
	ld a,(hl)
	cp #ff
	jr z,l51f5
	dec (hl)
	jp p,l51f5
	ld a,(l40d6)
	cpl
	ld hl,l509c
	or (hl)
	ld (hl),a
.l51f5
	call l53bd
	ld c,#07
	ld a,(l509c)
	and #3f
	call l53d4
	ld ix,l509d
	ld c,#00
	ld hl,(l50a0)
	ld a,(ix+#09)
	add l
	ld l,a
	ld a,(ix+#0a)
	adc h
	ld h,a
	ld a,(ix+#12)
	add l
	ld l,a
	ld a,(ix+#13)
	adc h
	push af
	ld a,l
	ld hl,#f680
	bit 1,(ix+#11)
	jp z,l522d
	ld (l50d9),a
.l522d
	call l53d4
	inc c
	pop af
	call l53d4
	inc c
	ld hl,(l50b4)
	ld a,(ix+#1d)
	add l
	ld l,a
	ld a,(ix+#1e)
	adc h
	ld h,a
	ld a,(ix+#26)
	add l
	ld l,a
	ld a,(ix+#27)
	adc h
	push af
	ld a,l
	ld hl,#f680
	bit 1,(ix+#25)
	jp z,l525b
	ld (l50d9),a
.l525b
	call l53d4
	inc c
	pop af
	call l53d4
	inc c
	ld hl,(l50c8)
	ld a,(ix+#31)
	add l
	ld l,a
	ld a,(ix+#32)
	adc h
	ld h,a
	ld a,(ix+#3a)
	add l
	ld l,a
	ld a,(ix+#3b)
	adc h
	push af
	ld a,l
	ld hl,#f680
	bit 1,(ix+#39)
	jp z,l5289
	ld (l50d9),a
.l5289
	call l53d4
	inc c
	pop af
	call l53d4
	inc c
	ld a,(l40d4)
	cp #ff
	jr z,l529f
	ld a,(l40d5)
	jp l52a2
.l529f
	ld a,(l50d9)
.l52a2
	rrca
	rrca
	rrca
	call l53d4
	ld c,#08
	ld a,(l50a2)
	srl a
	srl a
	srl a
	call l53d4
	inc c
	ld a,(l50b6)
	srl a
	srl a
	srl a
	call l53d4
	inc c
	ld a,(l50ca)
	srl a
	srl a
	srl a
	call l53d4
	jp l53c9
.l52d3
	ld a,(l509c)
	and (ix+#02)
	cp (ix+#02)
	ret z
	ld a,(ix+#0f)
	ld ly,a
	ld a,(ix+#10)
	ld hy,a
	ld a,(ix+#06)
	and a
	jr z,l52f4
	cp #ff
	jr z,l52f4
	dec (ix+#06)
.l52f4
	call l537b
	bit 2,(iy+#09)
	jp nz,l5374
	ld l,(ix+#0d)
	ld h,(ix+#0e)
	jp (hl)
.l5305
	ld a,(ix+#05)
	add (iy+#00)
	cp (iy+#04)
	jr nc,l5314
	ld (ix+#05),a
	ret
.l5314
	ld a,(iy+#04)
	ld (ix+#05),a
	ld hl,l5324
	ld (ix+#0d),l
	ld (ix+#0e),h
	ret
.l5324
	ld a,(ix+#05)
	add (iy+#01)
	jp m,l5336
	cp (iy+#02)
	jr c,l5336
	ld (ix+#05),a
	ret
.l5336
	ld a,(iy+#02)
	ld (ix+#05),a
	ld hl,l5346
	ld (ix+#0d),l
	ld (ix+#0e),h
	ret
.l5346
	ld a,(ix+#06)
	and a
	ret nz
	ld hl,l5355
	ld (ix+#0d),l
	ld (ix+#0e),h
	ret
.l5355
	ld a,(ix+#05)
	add (iy+#03)
	jp m,l5362
	ld (ix+#05),a
	ret
.l5362
	ld (ix+#05),#00
	ld a,(l509c)
	or (ix+#02)
	ld (l509c),a
	res 7,(ix+#11)
	ret
.l5374
	ld a,(ix+#06)
	and a
	ret nz
	jr l5362
.l537b
	ld a,(ix+#07)
	and a
	jr z,l5388
	cp #ff
	ret z
	dec (ix+#07)
	ret nz
.l5388
	ld l,(ix+#09)
	ld h,(ix+#0a)
	ld c,(ix+#0b)
	ld b,(ix+#0c)
	add hl,bc
	ld (ix+#09),l
	ld (ix+#0a),h
	dec (ix+#08)
	ret nz
	ld a,(iy+#06)
	and a
	ret z
	jp p,l53ac
	ld (ix+#07),#ff
	ret
.l53ac
	ld (ix+#08),a
	ld a,c
	cpl
	ld c,a
	ld a,b
	cpl
	ld b,a
	inc bc
	ld (ix+#0b),c
	ld (ix+#0c),b
	ret
.l53bd
	ld bc,#f782
	out (c),c
	ld de,#c000
	ld hl,#f680
	ret
.l53c9
	ld bc,#f40e
	out (c),c
	ld b,h
	out (c),d
	out (c),e
	ret
.l53d4
	ld b,#f4
	out (c),c
	ld b,h
	out (c),d
	out (c),e
	ld b,#f4
	out (c),a
	ld b,h
	out (c),l
	out (c),e
	ret

;call #40d7
;ld a,(#4006)
;or a
;call nz,&417d
;
.game_name
	db "Switch Blade",0
.game_year
	db "1990",0
.game_publisher
	db "Gremlin Graphics",0
.music_author
	db "Ben Daglish",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
